mmerge appln_id using ${commondata_dir}/patstat_2018b/family_info.dta, unmatched(master) ukeep(docdb_family_id)
drop _m
foreach ctry in DE RU {
	gen pat_ctry_`ctry' = `1' == "`ctry'"
	bys docdb_family_id : egen ctry_`ctry' = max(pat_ctry_`ctry')
	drop pat_ctry_`ctry'
}

drop if `1' == "DD" & ctry_DE
drop if `1' == "SU" & ctry_RU
replace `1'= "DE" if `1' == "DD"
replace `1'= "RU" if `1' == "SU"
drop ctry_DE ctry_RU
